package config.core;

import config.SecurityConfig;
import org.springframework.context.annotation.*;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 * Created by Reeves on 2017/8/19.
 */
@Configuration
@ComponentScan(basePackages = {"web"},
        excludeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class)
        })
// Spring Security的配置必须在WebXML中的getRootConfigClasses中引入，否则无法使用Spring Security的功能
@Import({SecurityConfig.class})
public class ApplicationContextXml {
        @Bean(name = "dataSource")
        public DriverManagerDataSource dataSource() {
                DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
                driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
                driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/springSecurity");
                driverManagerDataSource.setUsername("root");
                driverManagerDataSource.setPassword("legend1004");
                return driverManagerDataSource;
        }
}
